﻿using System;


namespace SaleDiscount.Portal.Common
{
    public class TimeHelper
    {

        /// <summary>
        /// Millis the time stamp.
        /// </summary>
        /// <param name="theDate">The date.</param>
        /// <returns></returns>
        public static long MilliTimeStamp(DateTime theDate)
        {
            DateTime d1 = new DateTime(1970, 1, 1);
            DateTime d2 = theDate.ToUniversalTime();
            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
            return (long)ts.TotalMilliseconds;
        }
        /// <summary>
        /// Gets the time zone.
        /// </summary>
        /// <returns></returns>
        public static int GetTimeZone()
        {
            DateTime now = DateTime.Now;
            var utcnow = now.ToUniversalTime();

            var sp = now - utcnow;

            return sp.Hours;
        }
        public static string GetTimeZoneString()
        {
            DateTime now = DateTime.Now;
            var utcnow = now.ToUniversalTime();

            var sp = now - utcnow;
            if (now > utcnow)
                return "+" + sp.ToString().Replace(":", "").Substring(0, 4);
            else
                return sp.ToString().Replace(":", "").Substring(0, 5);
        }
        public static DateTime GetStartDayOfMonth()
        {
         
            return new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
        }
        public static DateTime GetEndDayOfMonth()
        {
            return 
new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);     

        }



    }
}
